<?php
defined('_JEXEC') or die('Restricted access');

$joomla16_style = '';
$jversion = new JVersion();
if ($jversion->RELEASE != '1.5') {
  $joomla16_style = " border: 1px #CCC solid !important;";
}

?>
<table width="100%" style="border: #ccc 1px solid; background: #f9f9f9;"><tr><td valign="top"><p><h2>NS Pro Toolkit</h2></p>
<p>A collection of tools to make NS Pro easier to use.</p>
<p>
<table><tr><td style="width: 460px;">
<!-- Tool 1: editmail -->
<fieldset style="width: 450px;<?php print $joomla16_style; ?>">
<legend>Tool #1: Edit Subscriber</legend>
<form action="index.php?option=com_nspro&view=toolkit" method="post">
<table><tr><td>Edit By Email:</td>
<td><input type="text" size="40" class="nspro inputbox" name="editmail" /></td>
<td><input type="submit" class="nspro button" name="editmailsubmit" value="Edit Subscriber"/></td></tr>
</table></form>
</fieldset>
<!-- Tool 2: delmail -->
<fieldset style="width: 450px;<?php print $joomla16_style; ?>">
<legend>Tool #2: Delete Subscriber</legend>
<form action="index.php?option=com_nspro&view=toolkit" method="post">
<table><tr><td>Delete By Email:</td>
<td><input type="text" size="40" class="nspro inputbox" name="delmail" /></td>
<td><input type="submit" class="nspro button" name="delmailsubmit" value="Delete Subscriber"/></td></tr>
</table></form>
</fieldset>
<!-- Tool 3: newsletterToMail -->
<fieldset style="width: 450px;<?php print $joomla16_style; ?>">
<legend>Tool #3: Send Newsletter</legend>
<form action="index.php?option=com_nspro&view=toolkit" method="post">
<table>
<tr><td>Newsletter ID:</td><td><input type="text" size="25" class="nspro inputbox" name="newsletterIdToSend" /></td></tr>
<tr><td>Target Email:</td><td><input type="text" size="50" class="nspro inputbox" name="emailToSend" /></td></tr>
<tr><td colspan="2"><input type="submit" class="nspro button" name="newsletterToMail" value="Send Newsletter"/></td></tr>
</table></form>
</fieldset>
</td><td>
<!-- Tool 4: selnewslettersend -->
<fieldset style="width: 450px;<?php print $joomla16_style; ?>">
<legend>Tool #4: Selective Newsletter</legend>
<form action="index.php?option=com_nspro&view=toolkit" method="post">
<table><tr><td style="width: 80px;">Newsletter ID:</td>
<td><input type="text" size="20" class="nspro inputbox" name="newsletterIdToSend" /></td></tr>
<tr><td colspan="2">
<select multiple="multiple" name="subscribersToSend[]" size="11" style="width: 420px;">
<?php
  foreach ($subs as $sub) {
    print '<option value="' . $sub->id . '">' . $sub->id . ': ' . $sub->email . '</option>';
  }
?>
</select>
</td></tr>
<tr><td colspan="2"><input type="submit" class="nspro button" name="selnewslettersend" value="Send Newsletter"/></td></tr>
</table></form>
</fieldset>
</td></tr>
<tr><td colspan="2"><hr></td></tr>
<tr><td style="width: 460px;">
<!-- Tool 5: newsubquick -->
<fieldset style="width: 450px;<?php print $joomla16_style; ?>">
<legend>Tool #5: Quickly Create New Subscriber</legend>
<form action="index.php?option=com_nspro&view=toolkit" method="post">
<table>
<tr><td>Name:</td><td>
<input type="text" size="60" class="nspro inputbox" name="newsubname" />
</td>
</tr>
<tr><td>Email:</td><td>
<input type="text" size="60" class="nspro inputbox" name="newsubemail" />
</td>
</tr>
<tr><td>DateTime:</td><td>
<input type="text" size="60" class="nspro inputbox" name="newsubdatetime" />
</td>
</tr>
<tr><td>Confirmed:</td>
<td>
<?php if ($jversion->RELEASE != '1.5') { print '<fieldset class="radio inputbox">'; } ?>
<input type="radio" class="inputbox" checked="checked" value="0" id="confirmed0" name="newsubconfirmed">
<label for="confirmed0">No</label>
<input type="radio" class="inputbox" value="1" id="confirmed1" name="newsubconfirmed">
<label for="confirmed1">Yes</label>
<?php if ($jversion->RELEASE != '1.5') { print '</fieldset>'; } ?>
</td>
</tr>
<tr><td>Mailing Lists:</td>
<td>
<select id="mailing_lists2" name="newsubmailing_lists2[]" multiple="multiple" size="4" style="height: 60px; width: 200px;" class="inputbox">
<?php

$db->setQuery('SELECT `id`, `lname` FROM `#__nspro_lists`');
$mlists = $db->loadObjectList();

foreach($mlists as $mlist) {
  print '<option value="' . $mlist->id . '" id="list_' . $mlist->id . '"';
  print '>' . $mlist->lname . '</option>';
}
?>
</select>
</td>
</tr>
<tr><td>Notes:</td><td>
<input type="text" size="60" class="nspro inputbox" name="newsubnotes" />
</td>
</tr>
<tr><td colspan="2"><input type="submit" class="nspro button" name="createsubquick" value="Create Subscriber"/></td></tr>
</table></form>
</fieldset>
</td>
<td>
<!-- Tool 6: assigntomailinglist -->
<fieldset style="width: 450px;<?php print $joomla16_style; ?>">
<legend>Tool #6: Mass Assign to Mailing List</legend>
<form action="index.php?option=com_nspro&view=toolkit" method="post"><table><tr><td style="width: 80px;">Mailing List ID:</td><td>
<input type="text" size="20" class="nspro inputbox" name="mailinglisttoassignto" /></td></tr>
<tr>
<td colspan="2">
<select multiple="multiple" name="subscribersToAssign[]" size="11" style="width: 420px;">
<?php
  foreach ($subs as $sub) {
    print '<option value="' . $sub->id . '">' . $sub->id . ': ' . $sub->email . '</option>';
  }
?>
</select>
</td>
</tr>
<tr><td colspan="2"><input type="submit" class="nspro button" name="assigntomailinglist" value="Assign to Mailing List"/></td></tr>
</table></form>
</fieldset>
</td>
</tr>
</table>
</p>
<br/>
<!-- Tool 7: Migration Tool -->
<fieldset style="width: 450px;">
<legend>Tool #7: Migration Tool</legend>
<i>Note: Only DB records are migrated. Newsletter Images, Attachments or any other files must be copied manually.</i>
<table><tr>
<td>
<form action="index.php" method="post">
<input type="submit" class="nspro button" value="<?php print JText::_('Export Migration File') ?>"/>
<input type="hidden" name="option" value="com_nspro"/>
<input type="hidden" name="view" value="toolkit"/>
<input type="hidden" name="task" value="export_migration"/>
</form>
<br/>
</td></tr><tr><td>
<form enctype="multipart/form-data" action="index.php" method="POST" name="fileform">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
<input class="input_box" name="nspro_migration" type="file" size="57"/>
<input type="submit" class="nspro button" value="<?php print JText::_('Upload File & Import') ?>"/>
<input type="hidden" name="option" value="com_nspro"/>
<input type="hidden" name="view" value="toolkit"/>
<input type="hidden" name="task" value="import_migration"/>
</form>
</td>
</tr></table>
</fieldset>
<br/>
<p><small>Please suggest more tools at the <a href="http://mavrosxristoforos.com/forum">NS Pro Feature Request Forum</a></small></p>
</td></tr></table>